<?php
declare (strict_types=1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
use app\common\model\Assets;
use think\App;

class Transfer extends Base
{
    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Transfer';

    //关联模型
    protected array $hasOne = ['user', 'take'];


    public function index(): string
    {
        return Builder::Table()
            ->autoStructure($this->model, $this->pk)
            ->addTopButtons(['export'])
            ->addSearch([
                ['uid', '转账会员编号/昵称/手机号', 'input', '', '\app\common\model\User', 'code|nickname|mobile,id'],
                ['take_uid', '收账会员编号/昵称/手机号', 'input', '', '\app\common\model\User', 'code|nickname|mobile,id'],
                ['account', '账户类型', 'select', Assets::getFields(3)]
            ])
            ->addSwitchTool([['name' => 'is_lock', 'pk' => $this->pk, 'text' => '锁定|正常']])
            ->fetch();
    }

}
